
import {linkage,getbanner,reqFloorList} from '@/network/api'
const state = {
  //起始值为空
  categoryList: [],
  //轮播图数组
  bannerList: [],
  refFloor: []

};
const mutations = {
  CATEGORYLIST(state,categoryList){
    state.categoryList = categoryList;
  },
  GETBANNERLIST(state,bannerList){
    state.bannerList = bannerList
  },
  GETREQFLOORLIST(state,refFloor){
    state.refFloor = refFloor
  }
}
const actions = {
  //通过api接口函数调用
 async categoryList({commit}){
    let result = await linkage();
    //判断是否成功，成功则返回数据
    if(result.code == 200){
      commit("CATEGORYLIST",result.data)
    }  
  },
  //获取首页banner接口
  async getbannerList({commit}){
    let result = await getbanner();
    if(result.code==200){
      commit('GETBANNERLIST',result.data)
    }
  },
  //获取floor数据
  async getreqFloorList({commit}){
    let result = await reqFloorList()
    if(result.code==200){
      commit('GETREQFLOORLIST',result.data)
    }
  }
};
const getters = {};


//vuex模块化开发
export default {
  state,
  mutations,
  actions,
  getters
}